<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
<html xmlns="http://www.w3.org/1999/xhtml">
<head>
<meta http-equiv="Content-Type" content="text/xhtml;charset=UTF-8"/>
<meta http-equiv="X-UA-Compatible" content="IE=9"/>
<meta name="generator" content="Doxygen 1.8.13"/>
<meta name="viewport" content="width=device-width, initial-scale=1"/>
<title>CUDNN Frontend API: CUDNN FRONTEND API</title>
<link href="tabs.css" rel="stylesheet" type="text/css"/>
<script type="text/javascript" src="jquery.js"></script>
<script type="text/javascript" src="dynsections.js"></script>
<link href="navtree.css" rel="stylesheet" type="text/css"/>
<script type="text/javascript" src="resize.js"></script>
<script type="text/javascript" src="navtreedata.js"></script>
<script type="text/javascript" src="navtree.js"></script>
<script type="text/javascript">
  $(document).ready(initResizable);
</script>
<link href="search/search.css" rel="stylesheet" type="text/css"/>
<script type="text/javascript" src="search/searchdata.js"></script>
<script type="text/javascript" src="search/search.js"></script>
<link href="doxygen.css" rel="stylesheet" type="text/css" />
</head>
<body>
<div id="top"><!-- do not remove this div, it is closed by doxygen! -->
<div id="titlearea">
<table cellspacing="0" cellpadding="0">
 <tbody>
 <tr style="height: 56px;">
  <td id="projectalign" style="padding-left: 0.5em;">
   <div id="projectname">CUDNN Frontend API
   &#160;<span id="projectnumber">8.2.0</span>
   </div>
  </td>
 </tr>
 </tbody>
</table>
</div>
<!-- end header part -->
<!-- Generated by Doxygen 1.8.13 -->
<script type="text/javascript">
var searchBox = new SearchBox("searchBox", "search",false,'Search');
</script>
<script type="text/javascript" src="menudata.js"></script>
<script type="text/javascript" src="menu.js"></script>
<script type="text/javascript">
$(function() {
  initMenu('',true,false,'search.php','Search');
  $(document).ready(function() { init_search(); });
});
</script>
<div id="main-nav"></div>
</div><!-- top -->
<div id="side-nav" class="ui-resizable side-nav-resizable">
  <div id="nav-tree">
    <div id="nav-tree-contents">
      <div id="nav-sync" class="sync"></div>
    </div>
  </div>
  <div id="splitbar" style="-moz-user-select:none;" 
       class="ui-resizable-handle">
  </div>
</div>
<script type="text/javascript">
$(document).ready(function(){initNavTree('index.html','');});
</script>
<div id="doc-content">
<!-- window showing the filter options -->
<div id="MSearchSelectWindow"
     onmouseover="return searchBox.OnSearchSelectShow()"
     onmouseout="return searchBox.OnSearchSelectHide()"
     onkeydown="return searchBox.OnSearchSelectKey(event)">
</div>

<!-- iframe showing the search results (closed by default) -->
<div id="MSearchResultsWindow">
<iframe src="javascript:void(0)" frameborder="0" 
        name="MSearchResults" id="MSearchResults">
</iframe>
</div>

<div class="header">
  <div class="headertitle">
<div class="title">CUDNN FRONTEND API </div>  </div>
</div><!--header-->
<div class="contents">
<div class="textblock"><h1><a class="anchor" id="Introduction"></a>
Introduction</h1>
    <p>The <a href="https://github.com/NVIDIA/cudnn-frontend">cuDNN Frontend API</a> is a C++ header-only library that demonstrates how to use the cuDNN C backend API. The cuDNN C backend API is documented in the cuDNN developer guide.</p>
<h1><a class="anchor" id="Need"></a>
Why use Frontend API</h1>
<p>Consider the following code snippet which showcases cudnnBackendTensor creation using the backend API and its equivalent front-end API code. Many among the backend constructs follow similar pattern.</p>
<div class="fragment"><div class="line">===========================================================================================</div><div class="line"><span class="keyword">auto</span> check_status = [](cudnnStatus_t status) { assert (status == CUDNN_STATUS_SUCCESS); };</div><div class="line">===========================================================================================</div><div class="line"><span class="comment">// Backend code for Tensor Creation.</span></div><div class="line">cudnnBackendDescriptor_t tensor;</div><div class="line"></div><div class="line">check_status (cudnnBackendCreateDescriptor(CUDNN_BACKEND_TENSOR_DESCRIPTOR, &amp;tensor));</div><div class="line"></div><div class="line">check_status (cudnnBackendSetAttribute(tensor,</div><div class="line">                                       CUDNN_ATTR_TENSOR_DATA_TYPE,</div><div class="line">                                       CUDNN_TYPE_DATA_TYPE,</div><div class="line">                                       1,</div><div class="line">                                       &amp;data_type));</div><div class="line">check_status (cudnnBackendSetAttribute(tensor,</div><div class="line">                                       CUDNN_ATTR_TENSOR_DIMENSIONS,</div><div class="line">                                       CUDNN_TYPE_INT64,</div><div class="line">                                       tensor_dim.size(),</div><div class="line">                                       tensor_dim.data()));</div><div class="line">check_status (cudnnBackendSetAttribute(tensor,</div><div class="line">                                       CUDNN_ATTR_TENSOR_STRIDES,</div><div class="line">                                       CUDNN_TYPE_INT64,</div><div class="line">                                       tensor_str.size(),</div><div class="line">                                       tensor_str.data()));</div><div class="line">check_status (cudnnBackendSetAttribute(tensor,</div><div class="line">                                       CUDNN_ATTR_TENSOR_UNIQUE_ID,</div><div class="line">                                       CUDNN_TYPE_INT64,</div><div class="line">                                       1,</div><div class="line">                                       &amp;<span class="keywordtype">id</span>));</div><div class="line">check_status (cudnnBackendSetAttribute(tensor,</div><div class="line">                                       CUDNN_ATTR_TENSOR_BYTE_ALIGNMENT,</div><div class="line">                                       CUDNN_TYPE_INT64,</div><div class="line">                                       1,</div><div class="line">                                       &amp;alignment));</div><div class="line">check_status (cudnnBackendFinalize(tensor));</div><div class="line"></div><div class="line">check_status (cudnnBackendDestroyDescriptor(tensor));</div><div class="line">===========================================================================================</div><div class="line"><span class="comment">// FrontEnd equivalent code.</span></div><div class="line"><span class="keyword">auto</span> tensor =  <a class="code" href="df/de1/namespacecudnn__frontend.html#a9fea2e22198aaf2ea11a0df46abd0749">cudnn_frontend::TensorBuilder</a>()</div><div class="line">                   .<a class="code" href="d3/d3c/group__TensorBuilder__v8.html#gae828806e2d76ca3eb6c4e289f2e93a96">setDim</a>(tensor_dim.size(), tensor_dim.data())</div><div class="line">                   .setStrides(tensor_str.size(), tensor_str.data())</div><div class="line">                   .setId(<span class="keywordtype">id</span>)</div><div class="line">                   .setAlignment(alignment)</div><div class="line">                   .setDataType(data_type)</div><div class="line">                   .build();</div><div class="line">check_status(tensor.get_status());</div><div class="line">===========================================================================================</div></div><!-- fragment --><p>Frontend API serves two major purpose as a companion to the backend API.</p><ul>
<li>Functional additions:<ul>
<li>Support for auto-tuning. (cudnnGet and cudnnFind)</li>
<li>Errata filters.</li>
</ul>
</li>
<li>Programmatic ease:<ul>
<li>Easy memory management for the cudnnBackendDescriptor_t (RAII based classes).</li>
<li>Error handling with optional exception support. Better error messages.</li>
<li>Fewer lines of code (5-10x reduction in LOC).</li>
<li>Simpler samples on how to use the new API. </li>
</ul>
</li>
</ul>
</div></div><!-- contents -->
</div><!-- doc-content -->
<!-- start footer part -->
<div id="nav-path" class="navpath"><!-- id is needed for treeview function! -->
  <ul>
    <li class="footer">Generated by
    <a href="http://www.doxygen.org/index.html">
    <img class="footer" src="doxygen.png" alt="doxygen"/></a> 1.8.13 </li>
  </ul>
</div>
</body>
</html>
